home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Music Architecture / Mixed Bag / •Instrument Editor / Instrument Editor Menus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-06  |  2.4 KB  |  140 lines  |  [TEXT/KAHL]

  1. /*
  2.  * file: Instrument Editor Menus.c
  3.  *
  4.  * started 22 March 1992
  5.  * david van brink
  6.  *
  7.  */
  8.  
  9. /*--------------------------
  10.     Inclusions
  11. --------------------------*/
  12.  
  13. #include <Memory.h>
  14.  
  15. #include "BigEasy2.h"
  16. #include "BigEasyTextish.h"
  17.  
  18. #include "Instrument Editor.h"
  19. #include "Instrument Editor Menus.h"
  20.  
  21.  
  22. static void DoSomethingWithKnobs(TDoc *d);
  23.  
  24. /*--------------------------
  25.     Kode
  26. --------------------------*/
  27.  
  28.  
  29. SynthListHandle GetSynthesizerList(void)
  30. /*
  31.  * Return a handle to a list of synths
  32.  */
  33.     {
  34.     short synthCount;
  35.     SynthListHandle result;
  36.     SynthMenuEntry *sme;
  37.     OSErr thisError;
  38.     NoteAllocator na;
  39.  
  40.     na = OpenDefaultComponent(kNoteAllocatorType,0);
  41.  
  42.     synthCount = NAGetRegisteredMusicDevice(na,0,nil,nil,nil,nil);
  43.  
  44.     result = (void *)NewHandle(synthCount * sizeof(SynthMenuEntry) + sizeof(SynthList));
  45.     HLock((void *)result);
  46.  
  47.     (**result).synthCount = synthCount;
  48.     sme = &(**result).entry[0];
  49.  
  50.     while(synthCount)
  51.         {
  52.         MusicComponent mc;
  53.  
  54.         thisError = NAGetRegisteredMusicDevice(na,synthCount,
  55.                 &sme->synthType,
  56.                 sme->synthName,
  57.                 nil,
  58.                 &mc);
  59.         if(!sme->synthName[0])        /* no registered name? */
  60.             {
  61.             SynthesizerDescription sd;
  62.  
  63.             MusicGetDescription(mc,&sd);
  64.             BlockMove(sd.name,sme->synthName,sd.name[0]+1);
  65.             }
  66.         sme++;
  67.         synthCount--;
  68.         }
  69.  
  70.     CloseComponent(na);
  71.     return result;
  72.     }
  73.  
  74.  
  75. void DoSomethingWithKnobs(TDoc *d)
  76.     {
  77.     Rect allControls;
  78.  
  79.     MakeControlsFromKnobList(d,&allControls);
  80.  
  81.     d->visibleSliderBounds.top = d->visibleSliderBounds.bottom
  82.             = d->visibleSliderBounds.left = d->visibleSliderBounds.right = 0;
  83.     d->virtualSliderBounds = allControls;
  84.  
  85.     UpdateSliderKnobs(d);
  86.  
  87.  
  88.     FixForSize(d);
  89.     }
  90.  
  91.  
  92. void DoGlobalKnobs(short n, short menuItem, short menuRef)
  93.     {
  94.     TDoc *d;
  95.     ComponentResult result;
  96.  
  97.     d = &gDoc[n - kFirstDocWindow];
  98.  
  99.     d->whichList = mGlobalKnobs;
  100.  
  101.     DisposeEasyControlList(d->ecl);
  102.     d->ecl = NewEasyControlList(d->w,0);
  103.     DoSomethingWithKnobs(d);
  104.  
  105.     FixUpMenus(d);
  106.     }
  107.  
  108. void DoInstrumentKnobs(short n, short menuItem, short menuRef)
  109.     {
  110.     TDoc *d;
  111.     ComponentResult result;
  112.  
  113.     d = &gDoc[n - kFirstDocWindow];
  114.  
  115.     d->whichList = mInstrumentKnobs;
  116.  
  117.     DisposeEasyControlList(d->ecl);
  118.     d->ecl = NewEasyControlList(d->w,0);
  119.     DoSomethingWithKnobs(d);
  120.  
  121.     FixUpMenus(d);
  122.     }
  123.  
  124. void DoControllers(short n, short menuItem, short menuRef)
  125.     {
  126.     TDoc *d;
  127.     ComponentResult result;
  128.  
  129.     d = &gDoc[n - kFirstDocWindow];
  130.  
  131.     d->whichList = mControllers;
  132.  
  133.     DisposeEasyControlList(d->ecl);
  134.     d->ecl = NewEasyControlList(d->w,0);
  135.     DoSomethingWithKnobs(d);
  136.  
  137.     FixUpMenus(d);
  138.     }
  139.  
  140.